<?php
namespace Enchant_RPG_SHOP\Enchant;

use pocketmine\Server;
use pocketmine\Player;
use pocketmine\utils\Config;
use pocketmine\event\Listener;
use pocketmine\plugin\Plugin;
use pocketmine\plugin\PluginLoader;
use pocketmine\plugin\PluginBase;

use Enchant_RPG_SHOP\Enchant_RPG_SHOP as Main;

class TXT
{
	private $Main;

	public function __construct(Main $Main)
	{
		$this->Main = $Main;
		$dir = $this->Main->getDataFolder();
		$this->start();
	}
	
	public function start()
	{
		$dir = $this->Main->getDataFolder();
		@mkdir($dir);
            $this->Enchant_NBT = new Config($dir . 'Enchant_NBT.yml',Config::YAML,['Enchant' => 1]);
            $this->Tip = new Config($dir . 'Tip.yml',Config::YAML,$this->Tip());
		$this->set = new Config($dir . 'Enchant_Config.yml',Config::YAML,[]);
		$this->b = new Config($dir . 'Config.yml',Config::YAML,[]);
		$this->Money = new Config($dir . 'Money.json',Config::YAML,[]);
		$this->item = new Config($dir . 'item.yml',Config::YAML,$this->itemList());
		$set1 = $this->getConfigTxT();
		if(!$this->set->exists('设置'))
		{
			$this->Main->getLogger()->info('§4正在写入配置信息[' . $set1['配置版本'] . ']');
			$this->set->set('设置',$set1);
			$this->set->save();
		}
		else
		{
			$set = $this->set->get('设置');
			if($set['配置版本'] != $set1['配置版本'])
			{
				$this->Main->getLogger()->info('§4发现旧版本配置文件§6[' . $set['配置版本'] . ']§4版本,正在§c智能覆盖§4此版本§6[' . $set1['配置版本'] . ']§4!');
				$this->Main->getLogger()->info('§4这会尽量保留原设置,从而加入§c新的设置...');
				$as = array_merge($set1,$set);
				$as['上一个版本'] = $as['配置版本'];
				$as['配置版本'] = $set1['配置版本'];
				if(strstr($as['底部显示'],'格挡'))
				{
					$this->Main->getLogger()->info('§e版本因特殊原因，正在重置底部设置!');
					$as['底部显示'] = "                                                                       {动态线}
                                                                     §4▍  §d{生命} / {生命上限} 生命 ஐ
                                                                     §4▍  §2+{物攻}  物攻 ➹
                                                                     §4▍  §3+{物防}  物防 ♝
                                                                     §4▍  §e+{暴击}  暴击 ☄
                                                                     §4▍  §c+{抗暴}  抗暴 ♋
                                                                     {动态线}









";
				}
				$this->set->set('设置',$as);
				$this->set->save();
			}
		}
	}

	public function Tip()
	{
		return Array(
			'库版本' => '2.2.0'
		);
	}

	public function getConfigTxT()
	{
		return Array(
			'配置版本' => '2.4.0_b3',
			'支付自定义' => [
				'金币' => '金币',
                        '附魔券' => '附魔券',
                        '等级' => '等级',
                        '经验' => '经验',
                        '物品' => '物品'
			],
			'上一个版本' => 0,
			'底部' => '开',
			'底部动态框' => '开',
			'开发者模式' => '关',
			'白名单内成员才可创建商店' => '关',

			'后台才能执行附魔券操作' => '开',
			'在指定世界开启底部' => '关',
			'无限在未射中目标情况下也生效' => '关',
			'等级影响属性' => '开',
			'只开启血量和攻击属性' => '关',

			'底部世界' => ['世界一','世界二','按照这格式无限加',],
			'白名单' => [],
			'最大可扩展血量上限' => 100,
			'每级加血量上限' => 0,
			'每级加物攻' => 0,
			'等级上限' => 1000000,
			'双击冷却秒数' => 3,
			'宝石ID' => 264,
			'底部方式' => 'Tip',
			
			'底部显示' => "                                                                       {动态线}
                                                                     §4▍  §d{生命} / {生命上限} 生命 ஐ
                                                                     §4▍  §2+{物攻}  物攻 ➹
                                                                     §4▍  §3+{物防}  物防 ♝
                                                                     §4▍  §e+{暴击}  暴击 ☄
                                                                     §4▍  §c+{抗暴}  抗暴 ♋
                                                                     {动态线}









",

			'箱子商店' => [
				'商店开关' => True,
				'双击确认' => True,
				'价格表' => [
					'示范:附魔ID' => [
						'等级' => '价格',
						'如:1' => '1000',
						'等级1-等级2' => '之间的价格',
						'如:2-10' => '10000'
					],
					'0' => ['1-10000' => 1000],
					'1' => ['1-10000' => 1000],
					'2' => ['1-10000' => 1000],
					'3' => ['1-10000' => 1000],
					'4' => ['1-10000' => 1000],
					'5' => ['1-10000' => 1000],
					'6' => ['1-10000' => 1000],
					'7' => ['1-10000' => 1000],
					'8' => ['1-10000' => 1000],
					'9' => ['1-10000' => 1000],
					'10' => ['1-10000' => 1000],
					'11' => ['1-10000' => 1000],
					'12' => ['1-10000' => 1000],
					'13' => ['1-10000' => 1000],
					'14' => ['1-10000' => 1000],
					'15' => ['1-10000' => 1000],
					'16' => ['1-10000' => 1000],
					'17' => ['1-10000' => 1000],
					'18' => ['1-10000' => 1000],
					'19' => ['1-10000' => 1000],
					'20' => ['1-10000' => 1000],
					'21' => ['1-10000' => 1000],
					'22' => ['1-10000' => 1000],
					'23' => ['1-10000' => 1000],
					'24' => ['1-10000' => 1000]
				] 
			]
		);
	}

	public function itemList()
	{
		return Array(
		    "1:0" => "石头",
            "2:0" => "草方块",
            "3:0" => "泥土",
            "4:0" => "圆石",
            "98:0" => "石砖",
            "98:1" => "苔石砖",
            "98:2" => "裂石砖",
            "98:3" => "錾制石砖",
            "48:0" => "苔石",
            "5:0" => "橡木木板",
            "5:1" => "云杉木板",
            "5:2" => "白桦木板",
            "5:3" => "丛林木板",
            "5:4" => "金合欢木板",
            "5:5" => "深色橡木木板",
            "45:0" => "砖块",
            "1:1" => "花岗岩",
            "1:2" => "磨制花岗岩",
            "1:3" => "闪长岩",
            "1:4" => "磨制闪长岩",
            "1:5" => "安山岩",
            "1:6" => "磨制安山岩",
            "243:0" => "灰化土",
            "110:0" => "菌丝",
            "82:0" => "粘土",
            "172:0" => "硬化粘土",
            "159:0" => "白色染色粘土",
            "159:1" => "橙色染色粘土",
            "159:2" => "品红染色粘土",
            "159:3" => "淡蓝色染色粘土",
            "159:4" => "黄色染色粘土",
            "159:5" => "黄绿色染色粘土",
            "159:6" => "粉色染色粘土",
            "159:7" => "灰色染色粘土",
            "159:8" => "淡灰色染色粘土",
            "159:9" => "青色染色粘土",
            "159:10" => "紫色染色粘土",
            "159:11" => "蓝色染色粘土",
            "159:12" => "棕色染色粘土",
            "159:13" => "绿色染色粘土",
            "159:14" => "红色染色粘土",
            "159:15" => "黑色染色粘土",
            "24:0" => "沙石",
            "24:1" => "磨制沙石",
            "24:2" => "平滑沙石",
            "12:0" => "沙子",
            "12:1" => "红沙",
            "13:0" => "沙砾",
            "17:0" => "橡木",
            "17:1" => "云杉木",
            "17:2" => "白桦木",
            "17:3" => "丛林木",
            "162:0" => "金合欢木",
            "162:1" => "深色橡木",
            "112:0" => "地狱砖块",
            "87:0" => "地狱岩",
            "88:0" => "灵魂沙",
            "7:0" => "基岩",
            "67:0" => "石楼梯",
            "53:0" => "橡木楼梯",
            "134:0" => "云杉木楼梯",
            "135:0" => "桦木楼梯",
            "136:0" => "丛林楼梯",
            "163:0" => "金合欢木楼梯",
            "164:0" => "深色橡木楼梯",
            "108:0" => "砖楼梯",
            "128:0" => "沙石楼梯",
            "109:0" => "石砖楼梯",
            "114:0" => "地狱砖楼梯",
            "156:0" => "石英楼梯",
            "44:0" => "石台阶",
            "44:3" => "圆石台阶",
            "158:0" => "橡木台阶",
            "158:1" => "云杉木台阶",
            "158:2" => "橡木台阶",
            "158:3" => "丛林木台阶",
            "158:4" => "金合欢木台阶",
            "158:5" => "深色橡木台阶",
            "44:4" => "砖台阶",
            "44:1" => "沙石台阶",
            "44:5" => "石砖台阶",
            "44:6" => "石英台阶",
            "44:7" => "地狱砖台阶",
            "155:0" => "石英块",
            "155:1" => "錾制石英块",
            "155:2" => "竖纹石英块",
            "16:0" => "煤矿石",
            "15:0" => "铁矿石",
            "14:0" => "金矿石",
            "56:0" => "钻石矿石",
            "21:0" => "青金石矿石",
            "73:0" => "红石矿石",
            "129:0" => "绿宝石矿石",
            "153:0" => "下界石英矿石",
            "49:0" => "黑曜石",
            "79:0" => "冰",
            "174:0" => "浮冰",
            "80:0" => "雪",
            "121:0" => "末地石",
            "165:0" => "粘液块",
            "139:0" => "圆石墙",
            "139:1" => "苔石墙",
            "111:0" => "睡莲",
            "41:0" => "金块",
            "42:0" => "铁块",
            "57:0" => "钻石块",
            "22:0" => "青金石块",
            "173:0" => "煤炭块",
            "133:0" => "绿宝石块",
            "152:0" => "红石块",
            "78:0" => "顶层雪",
            "20:0" => "玻璃",
            "89:0" => "萤石",
            "106:0" => "藤蔓",
            "65:0" => "梯子",
            "19:0" => "海绵",
            "102:0" => "玻璃板",
            "324:0" => "橡木门",
            "427:0" => "云杉木门",
            "428:0" => "白桦木门",
            "429:0" => "丛林木门",
            "430:0" => "金合欢木门",
            "431:0" => "深色橡木门",
            "330:0" => "铁门",
            "96:0" => "活板门",
            "167:0" => "铁活板门",
            "85:0" => "橡木栅栏",
            "85:1" => "云杉木栅栏",
            "85:2" => "白桦木栅栏",
            "85:3" => "丛林木栅栏",
            "85:4" => "金合欢木栅栏",
            "85:5" => "深色橡木栅栏",
            "113:0" => "地狱砖栅栏",
            "107:0" => "橡木栅栏门",
            "184:0" => "白桦木栅栏门",
            "183:0" => "云杉木栅栏门",
            "186:0" => "深色橡木栅栏门",
            "185:0" => "丛林木栅栏门",
            "187:0" => "金合欢木栅栏门",
            "101:0" => "铁栏杆",
            "355:0" => "床",
            "47:0" => "书架",
            "321:0" => "画",
            "389:0" => "物品展示栏",
            "58:0" => "工作台",
            "245:0" => "切石机",
            "54:0" => "箱子",
            "146:0" => "陷阱箱",
            "61:0" => "熔炉",
            "379:0" => "酿造台",
            "380:0" => "炼药锅",
            "25:0" => "音符盒",
            "120:0" => "末地传送门",
            "145:0" => "铁砧",
            "145:4" => "轻微损坏的铁砧",
            "145:8" => "严重损坏的铁砧",
            "37:0" => "蒲公英",
            "38:0" => "罂粟",
            "38:1" => "兰花",
            "38:2" => "绒球葱",
            "38:3" => "茜草花",
            "38:4" => "红色郁金香",
            "38:5" => "橙色郁金香",
            "38:6" => "白色郁金香",
            "38:7" => "粉色郁金香",
            "38:8" => "滨菊",
            "175:0" => "向日葵",
            "175:1" => "丁香",
            "175:2" => "高草丛",
            "175:3" => "大型蕨",
            "175:4" => "玫瑰丛",
            "175:5" => "牡丹",
            "39:0" => "蘑菇",
            "40:0" => "蘑菇",
            "99:14" => "蘑菇",
            "100:14" => "蘑菇块",
            "99:0" => "蘑菇",
            "99:10" => "蘑菇",
            "81:0" => "仙人掌",
            "103:0" => "西瓜",
            "86:0" => "南瓜",
            "91:0" => "南瓜灯",
            "30:0" => "蜘蛛网",
            "170:0" => "干草块",
            "31:1" => "草",
            "31:2" => "蕨",
            "32:0" => "枯死的灌木",
            "6:0" => "橡木树苗",
            "6:1" => "云杉树苗",
            "6:2" => "白桦树苗",
            "6:3" => "丛林树苗",
            "6:4" => "金合欢树苗",
            "6:5" => "深色橡木树苗",
            "18:0" => "橡树树叶",
            "18:1" => "云杉树叶",
            "18:2" => "白桦树叶",
            "18:3" => "丛林树叶",
            "161:0" => "金合欢树叶",
            "161:1" => "深色橡木树苗",
            "354:0" => "蛋糕",
            "397:0" => "骷髅头颅",
            "397:1" => "凋灵骷髅头颅",
            "397:2" => "僵尸的头",
            "397:3" => "头",
            "397:4" => "爬行者的头",
            "323:0" => "告示牌",
            "390:0" => "花盆",
            "52:0" => "刷怪箱",
            "116:0" => "附魔台",
            "35:0" => "羊毛",
            "35:8" => "淡灰色羊毛",
            "35:7" => "灰色羊毛",
            "35:15" => "黑色羊毛",
            "35:12" => "棕色羊毛",
            "35:14" => "红色羊毛",
            "35:1" => "橙色羊毛",
            "35:4" => "黄色羊毛",
            "35:5" => "黄绿色羊毛",
            "35:13" => "绿色羊毛",
            "35:9" => "青色羊毛",
            "35:3" => "淡蓝色羊毛",
            "35:11" => "蓝色羊毛",
            "35:10" => "紫色羊毛",
            "35:2" => "品红色羊毛",
            "35:6" => "粉色羊毛",
            "171:0" => "地毯",
            "171:8" => "淡灰色地毯",
            "171:7" => "灰色地毯",
            "171:15" => "黑色地毯",
            "171:2" => "品红色地毯",
            "171:14" => "红色地毯",
            "171:1" => "橙色地毯",
            "171:4" => "黄色地毯",
            "171:5" => "黄绿色地毯",
            "171:13" => "绿色地毯",
            "171:9" => "青色地毯",
            "171:3" => "淡蓝色地毯",
            "171:11" => "蓝色地毯",
            "171:10" => "紫色地毯",
            "171:6" => "粉红色地毯",
            "66:0" => "铁轨",
            "126:0" => "激活铁轨",
            "28:0" => "探测铁轨",
            "50:0" => "火把",
            "325:0" => "桶",
            "325:1" => "牛奶",
            "325:8" => "水桶",
            "325:10" => "岩浆桶",
            "46:0" => "TNT",
            "331:0" => "红石",
            "261:0" => "弓",
            "346:0" => "钓鱼竿",
            "259:0" => "打火石",
            "359:0" => "剪刀",
            "347:0" => "钟",
            "345:0" => "指南针",
            "328:0" => "矿车",
            "333:0" => "橡木船",
            "333:1" => "杉木船",
            "333:2" => "桦木船",
            "333:3" => "木船",
            "333:4" => "相思船",
            "333:5" => "黑橡木船",
            "383:15" => "村民幼体",
            "383:10" => "鸡幼崽",
            "383:11" => "牛幼崽",
            "383:12" => "猪幼崽",
            "246:0" => "发光的黑曜石",
            "247:0" => "下界反映盒",
            "383:13" => "绵羊幼崽",
            "383:14" => "狼幼崽",
            "383:22" => "豹猫幼崽",
            "383:16" => "蘑菇幼体",
            "383:32" => "僵尸幼体",
            "383:36" => "僵尸猪人幼体",
            "383:17" => "鱿鱼幼体",
            "383:40" => "洞穴蜘蛛幼崽",
            "383:42" => "岩浆怪幼体",
            "383:41" => "妖鬼幼体",
            "383:43" => "火焰幼体",
            "268:0" => "木剑",
            "290:0" => "木锄",
            "269:0" => "木锹",
            "270:0" => "木镐",
            "271:0" => "木斧",
            "272:0" => "石剑",
            "291:0" => "石锄",
            "273:0" => "石锹",
            "274:0" => "石镐",
            "275:0" => "石斧",
            "267:0" => "铁剑",
            "292:0" => "铁锄",
            "256:0" => "铁锹",
            "257:0" => "铁镐",
            "258:0" => "铁斧",
            "276:0" => "钻石剑",
            "293:0" => "钻石锄",
            "277:0" => "钻石锹",
            "278:0" => "钻石镐",
            "279:0" => "钻石斧",
            "283:0" => "金剑",
            "294:0" => "金锄",
            "284:0" => "金锹",
            "285:0" => "金镐",
            "286:0" => "金斧",
            "298:0" => "皮革帽子",
            "299:0" => "皮革外套",
            "300:0" => "皮革裤子",
            "301:0" => "皮革靴子",
            "302:0" => "锁链头盔",
            "303:0" => "锁链胸甲",
            "304:0" => "锁链护腿",
            "305:0" => "锁链靴子",
            "306:0" => "铁头盔",
            "307:0" => "铁胸甲",
            "308:0" => "铁护腿",
            "309:0" => "铁靴子",
            "310:0" => "钻石头盔",
            "311:0" => "钻石护甲",
            "312:0" => "钻石护腿",
            "313:0" => "钻石靴子",
            "314:0" => "金头盔",
            "315:0" => "金胸甲",
            "316:0" => "金护腿",
            "317:0" => "金靴子",
            "69:0" => "拉杆",
            "123:0" => "红石灯",
            "76:0" => "红石火把",
            "72:0" => "木质压力板",
            "70:0" => "石质压力板",
            "147:0" => "测重压里板",
            "148:0" => "测重压力板",
            "143:0" => "按钮",
            "77:0" => "按钮",
            "151:0" => "阳光传感器",
            "131:0" => "绊线钩",
            "365:0" => "生鸡肉",
            "125:3" => "投掷器",
            "23:3" => "发射器",
            "332:0" => "雪球",
            "263:0" => "煤炭",
            "263:1" => "木炭",
            "264:0" => "钻石",
            "265:0" => "铁锭",
            "266:0" => "金锭",
            "388:0" => "绿宝石",
            "280:0" => "木棍",
            "281:0" => "碗",
            "287:0" => "线",
            "288:0" => "羽毛",
            "318:0" => "燧石",
            "334:0" => "皮革",
            "415:0" => "兔子皮",
            "353:0" => "糖",
            "406:0" => "下界石英",
            "339:0" => "纸",
            "360:0" => "西瓜片",
            "262:0" => "箭",
            "352:0" => "骨头",
            "338:0" => "甘蔗",
            "296:0" => "小麦",
            "295:0" => "小麦种子",
            "361:0" => "南瓜种子",
            "362:0" => "西瓜种子",
            "458:0" => "甜菜根种子",
            "260:0" => "苹果",
            "466:0" => "金苹果",
            "349:0" => "生鱼",
            "460:0" => "生鲑鱼",
            "461.0" => "小丑鱼",
            "462:0" => "河豚",
            "463:0" => "熟鲑鱼",
            "367:0" => "腐肉",
            "282:0" => "蘑菇煲",
            "297:0" => "面包",
            "319:0" => "生猪肉",
            "320:0" => "熟猪肉",
            "366:0" => "熟鸡肉",
            "363:0" => "生牛肉",
            "364:0" => "牛排",
            "391:0" => "胡萝卜",
            "392:0" => "马铃薯",
            "393:0" => "烤马铃薯",
            "394:0" => "毒马铃薯",
            "357:0" => "曲奇",
            "400:0" => "南瓜派",
            "411:0" => "生兔肉",
            "412:0" => "熟兔肉",
            "413:0" => "兔肉煲",
            "378:0" => "岩浆膏",
            "369:0" => "烈焰棒",
            "371:0" => "金粒",
            "396:0" => "金萝卜",
            "382:0" => "闪烁的西瓜",
            "414:0" => "兔子腿",
            "370:0" => "恶魂之泪",
            "341:0" => "粘液球",
            "377:0" => "烈焰粉",
            "372:0" => "地狱疣",
            "289:0" => "火药",
            "348:0" => "萤石粉",
            "375:0" => "蜘蛛眼",
            "376:0" => "发酵蛛眼",
            "384:0" => "附魔之瓶",
            "351:0" => "红玫瑰",
            "351:8" => "灰色染料",
            "351:7" => "淡灰色染料",
            "351:15" => "骨粉",
            "351:12" => "淡蓝色染料",
            "351:14" => "橙色染料",
            "351:4" => "青金石",
            "351:5" => "紫色染料",
            "351:13" => "品红色染料",
            "351:9" => "粉红色染料",
            "351:3" => "可可豆",
            "351:11" => "蒲公英黄",
            "351:10" => "黄绿色染料",
            "351:2" => "仙人掌绿",
            "351:6" => "青色染料",
            "373:6" => "夜视药水",
            "373:8" => "隐身药水",
            "373:11" => "跳跃药水"
		);
	}
}